from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Food(Item):
    def __init__(self):
        Item.__init__(self, "food")    # do basic initialization for every item
        self.has_food = True
        
        # build list of actions
        self.add_action(Eat)
    
    def get_description(self):
        if self.has_food ==True:
            return "Food"
        else:
            return "Food (eaten)"

# define actions for this item

class Eat(Action):
    def __init__(self):
        Action.__init__(self, "eat")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Eat Food"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # turn lamp on and add cutscene
    def do_action(self,game,room,request):
        if self.item.has_food == True:
            set_cutscene("You eat the food.")
            self.item.has_food = False
        else:
            set_cutscene("Your bag is empty, brother.")
        return